<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ page import="com.cr.model.Customer"%>
<%@ page import="com.cr.model.Favorite"%>
<%@ page import="com.cr.service.FavoriteService"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My Favorites</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<link rel="stylesheet" type="text/css" href="easyui/themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="easyui/themes/icon.css">
	<link rel="stylesheet" type="text/css" href="style/style.css">
	<script type="text/javascript" src="easyui/jquery-1.7.2.min.js"></script>
	<script type="text/javascript" src="easyui/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="script/main.js"></script>
  </head>
  
  <body>
   	<jsp:include page="header.jsp"></jsp:include>
    <div id="content">
    	<div id="orders">
    		<%
    			Customer customer=null;
    		 	if(session.getAttribute("customer")!=null)
    		 	{
    		 		customer=(Customer)session.getAttribute("customer");
    		 	}
    		 	if(customer==null)
    		 	{
    		 		out.print("<script>location.href='login.jsp';</script>");
    		 	}
    			FavoriteService service=new FavoriteService();
    			List<Favorite> list=service.getFavorites(customer.getId());
    		 %>
    		 <div style="padding-top:50px;">
    		 	<div>
    		 		<p style="font-weight:600;text-align:left;">My Favorites:</p>
    		 			<table>
    		 				<%
			    		 		for(int i=0;i<list.size();i++)
			    		 		{
			    		 			if(i==0||i%4==0)
			    		 			{
			    		 				out.print("<tr>");
			    		 			}
			    		 			Favorite favorite=list.get(i);
			    		 			out.print("<td style='border-bottom:dashed 1px gray;padding-right:10px;' width='25%'><p><img src='"+favorite.getClothPicture()+"' style='width:70px;height:100px;'/><img src='images/cancel.png' alt='cancel this favorite' onclick='cancelFavorite("+favorite.getId()+")'/></p><p style='width:150px;'>"+favorite.getClothName()+"</p></td>");
			    		 			
			    		 			if(i==list.size()-1 || i%4==3)
			    		 			{
			    		 				out.print("</tr>");
			    		 			}
			    		 		}
			    		 	  %>
    		 			</table>
    		 	</div>
    		 </div>
    	</div>
    </div>
    <jsp:include page="footer.jsp"></jsp:include>
  </body>
</html>
